import 'package:flutter/material.dart';

import 'click_widget.dart';

class CommonWHButton extends StatelessWidget {
  const CommonWHButton(this.text,
      {Key? key,
      this.onTap,
      this.width,
      this.height,
      this.borderRadius,
      this.color,
      this.border,
      this.child,
      this.timeout})
      : super(key: key);

  final String text;
  final GestureTapCallback? onTap;
  final double? width;
  final double? height;
  final double? borderRadius;
  final Color? color;
  final Border? border;
  final Widget? child;
  final int? timeout;

  @override
  Widget build(BuildContext context) {
    return ClickWidget(
      /// 按指定时间节流
      type: ClickType.throttleWithTimeout,
      timeout: timeout,
      onTap: onTap,
      child: Container(
          height: height,
          width: width,
          alignment: Alignment.center,
          decoration: new BoxDecoration(
            color: color,
            border: border,
            borderRadius: BorderRadius.all(Radius.circular(borderRadius ?? 0.0)),
          ),
          child: child),
    );
  }
}

class CommonMaginButton extends StatelessWidget {
  const CommonMaginButton(this.text,
      {Key? key,
      this.onTap,
      this.margin,
      this.padding,
      this.height,
      this.borderRadius,
      this.color,
      this.border,
      this.gradient,
      this.child,
      this.timeout})
      : super(key: key);

  final String text;
  final GestureTapCallback? onTap;
  final EdgeInsetsGeometry? margin;
  final EdgeInsetsGeometry? padding;
  final double? height;
  final double? borderRadius;
  final Color? color;
  final Border? border;
  final Gradient? gradient;
  final Widget? child;
  final int? timeout;

  @override
  Widget build(BuildContext context) {
    return ClickWidget(

        /// 按指定时间节流
        type: ClickType.throttleWithTimeout,
        timeout: timeout,
        onTap: onTap,
        child: Container(
            margin: margin,
            padding: padding,
            height: height,
            alignment: Alignment.center,
            decoration: new BoxDecoration(
              color: color,
              border: border,
              gradient: gradient,
              borderRadius: BorderRadius.all(Radius.circular(borderRadius ?? 0.0)),
            ),
            child: child));
  }
}
